from fastapi.responses import ORJSONResponse
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, Any, List, Dict

from .response_code import HttpCode

class CustomResponse(ORJSONResponse):
    """自定义响应
    """
    pass

class CustomContent(BaseModel):
    """响应体类
    """
    code: int               = Field(alias='code')
    msg: Optional[str]      = Field(default=None, alias='msg')
    data: Optional[Any]     = Field(default=None, alias='data')
    
    model_config = ConfigDict(populate_by_name=True)
    
    def to_dict(self, exclude: List[str] = None) -> Dict:
        return self.model_dump(exclude=exclude)